package com.resumes.resumesdataservice.mapper;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.resumes.resumesdataservice.domain.ListStudent;
import com.resumes.resumesdataservice.domain.Student;
import com.resumes.resumesdataservice.domain.TextInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper extends BaseMapper<Student> {

    @Select("select id,name,jobIntention,age,major,bg_color,up_img from Student,wxss where id = student_id")
    List<ListStudent> newList();


    @Select("select S.id,name,age,contactInformation,email,major,jobIntention," +
            "introduction,skills,awardPrize,projectName,projectInfo,photoPath,filepath,videopath " +
            "from Student S " +
            "left join ProjectExperience PE on S.id = PE.student_id " +
            "left join AwardInformation AI on S.id = AI.student_id " +
            "left join video v on S.id = v.student_id " +
            "left join StudentPhoto SP on S.id = SP.student_id " +
            "left join File F on S.id = F.student_id " +
            "where S.id = #{id}")
    TextInfo getInfo(String id);

    //id,name,jobIntention,age,major,bg_color,up_img
    @Select("select S.id,name,age,contactInformation,email,major,jobIntention," +
            "introduction,skills,awardPrize,projectName,projectInfo,photoPath,filepath,videopath,bg_color,up_img " +
            "from Student S " +
            "left join ProjectExperience PE on S.id = PE.student_id " +
            "left join AwardInformation AI on S.id = AI.student_id " +
            "left join video v on S.id = v.student_id " +
            "left join StudentPhoto SP on S.id = SP.student_id " +
            "left join File F on S.id = F.student_id " +
            "left join wxss w on S.id = w.student_id " +
            "where name like #{args} or major like #{args} or jobIntention like #{args} " +
            "or introduction like #{args} or skills like #{args} " +
            "or awardPrize like #{args} or projectName like #{args} or projectInfo like #{args} " +
            "or contactInformation like #{args} or email like #{args} " +
            "or filepath like #{args} or videopath like #{args} or photoPath like #{args} " +
            "or bg_color like #{args} or up_img like #{args}")
    List<ListStudent> searchByArgs(String args);


    @Select("select loginid,loginpwd from Student where loginid = #{id} and loginpwd = #{pwd}" +
            " group by loginid")
    Student login(String id, String pwd);
}